package logic

import (
	"context"
	"order/model/redis"

	"order/internal/svc"
	"order/order"

	"github.com/zeromicro/go-zero/core/logx"
)

type DeleteGoodLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewDeleteGoodLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteGoodLogic {
	return &DeleteGoodLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *DeleteGoodLogic) DeleteGood(in *order.DeleteGoodRequest) (*order.DeleteGoodResponse, error) {
	// todo: add your logic here and delete this line
	err := redis.DelShopStock(int(in.Id), int(in.GoodNum))
	if err != nil {
		return nil, err
		logx.Error(err)
	}
	return &order.DeleteGoodResponse{}, nil
}
